    var m3u8_url = document.getElementById('v').value;
    var title = document.title;
    //var js = {"url":m3u8_url,"title":title};
    //alert(JSON.stringify(js));
    //获取m3u8的内容
    //getM3U8(m3u8_url);
    //notify(JSON.stringify({"url":url,"title":title}));
    //alert("");

    isOpenJar(m3u8_url);

    function isOpenJar(m3u8_url){
        var request = "123123";

        notify_CORS(request,function(data){
            console.log("response==="+data);
            if( data == "ok"){
                console.log("local server is ONLINE");
                getM3U8(m3u8_url);
            }
            else{
                console.log("local server is not OFF_LINE");
            }
        });

    }
    function getM3U8(m3u8_url){
        var response = GET(m3u8_url);
        console.log("response=="+response);
        //解析结果
        var pattern = /https[\s\S]*?Ciphertext[\s\S]*?\"/;
        var keyUrls = pattern.exec(response);
        if(keyUrls==undefined || keyUrls.length <= 0){
            //直接通知下载
             var js = {"url":m3u8_url,"title":title,"key":"null"};
             //alert(JSON.stringify(js));
             notify(JSON.stringify(js));
        }
        else{
            //没有key，没有加密的视频
            var keyUrl = keyUrls[0];
            //key地址
            keyUrl = keyUrl.substring(0,keyUrl.length-1);
            //   alert("data"+keyUrl);
            getKeyUrlByData(keyUrl);
        }
    }
    function notify(data){
        notify_CORS(data,null);
    }
    function notify_CORS(data,callback){
        var url = "http:127.0.0.1:12345/test.php";
        function createCORS(method, url){
            var xhr = new XMLHttpRequest();
            if('withCredentials' in xhr){
                xhr.open(method, url, true);
            }else if(typeof XDomainRequest != 'undefined'){
                xhr = new XDomainRequest();
                xhr.open(method, url);
            }else{
                xhr = null;
            }
            return xhr;
        }

        var request = createCORS('post',url);
        if(request){
            request.onload = function(response){
                console.log("get response=="+request.response);
                if( !!callback ){
                    callback(request.response);
                }
            };
            request.send(data);
       }
    }
    function MOT_USE_notify(data){
        var url = "http:127.0.0.1:12345/test.php";

        console.log("sendData==="+data);
        var httpRequest = new XMLHttpRequest();//第一步：建立所需的对象
        httpRequest.open('POST', url, true);//第二步：打开连接  将请求参数写在url中  ps:"./Ptest.php?name=test&nameone=testone"
        httpRequest.send(data);//第三步：发送请求  将请求参数写在URL中

        var response = httpRequest.responseText;

        httpRequest.onreadystatechange = function () {
            if ( httpRequest.readyState === 4 && ( httpRequest.status>=200 && httpRequest.status<300 )  ){
                var response = httpRequest.responseText;

            }
        };
    }
    //同步调用，阻塞调用
    function GET(url ){
        var httpRequest = new XMLHttpRequest();//第一步：建立所需的对象
        httpRequest.open('GET', url, false);//第二步：打开连接  将请求参数写在url中  ps:"./Ptest.php?name=test&nameone=testone"
        httpRequest.setRequestHeader("Accept-Language","zh");
        //httpRequest.setRequestHeader("Accept-Encoding","gzip");
        //httpRequest.setRequestHeader("Origin","https://ke.yijincc.com");
        httpRequest.setRequestHeader("Accept","*/*");
        httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        //httpRequest.setRequestHeader("Referer","https://ke.yijincc.com/study-1442.htm");
        //httpRequest.responseType = "arraybuffer";
        httpRequest.send();//第三步：发送请求  将请求参数写在URL中
        return httpRequest.response;
    }
     //同步调用，阻塞调用
    function getKeyUrlByData(url ){
        var httpRequest = new XMLHttpRequest();//第一步：建立所需的对象
        httpRequest.open('GET', url, true);//第二步：打开连接  将请求参数写在url中  ps:"./Ptest.php?name=test&nameone=testone"
        //httpRequest.setRequestHeader("Accept-Language","zh");
        //httpRequest.setRequestHeader("Accept-Encoding","gzip");
        //httpRequest.setRequestHeader("Origin","https://ke.yijincc.com");
        //httpRequest.setRequestHeader("Accept","*/*");
       // httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        httpRequest.responseType = "arraybuffer";
        httpRequest.onload = function (oEvent) {
            var arrayBuffer = httpRequest.response; // 注意:不是oReq.responseText
            if (arrayBuffer) {
                console.log("arrayBuffer=="+arrayBuffer);
                var b64 = strToHex(arrayBuffer);
                if( b64.length == 32 ){
                    var js = {"url":m3u8_url,"title":title,"key":b64};
                    //alert(JSON.stringify(js));
                    notify(JSON.stringify(js));
                    return;
                }
                else{
                    alert("获取失败");
                    return;
                }
            }
        };
        httpRequest.send(null);//第三步：发送请求  将请求参数写在URL中
    }

    function strToHex(arrayBuffer){

        let res = "";
        var byteArray = new Uint8Array(arrayBuffer);
        for (var i = 0; i < byteArray.byteLength; i++) {
            // 对数组中的每个字节进行操作
            let code = byteArray[i];
            console.log("index="+i+"__code=="+code);
            let tmp = ((code).toString(16));
            if (tmp.length==1){
                res +=( "0"+tmp);
            }
            else{
                res += tmp;
            }
        }
        return res;
    }
    function strToHex2(str){
        let res = "";
        let tmp = "";
        console.log("str.length=="+str.length);
        for(var i=0;i<str.length;i++){
            // let code = str.charCodeAt(i) ;
            let code = str[i].charCodeAt() & 0xFF;
            console.log("index="+i+"__code=="+code);

            tmp = ((code).toString(16));
            if (tmp.length==1){
                res +=( "0"+tmp);
            }
            else{
                res += tmp;
            }
        }
        return res;
    };